<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户管理 - AI简历分析系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <style>
        :root {
            --primary-color: #4e73df;
            --secondary-color: #858796;
            --success-color: #1cc88a;
            --info-color: #36b9cc;
            --warning-color: #f6c23e;
            --danger-color: #e74a3b;
            --light-color: #f8f9fc;
            --dark-color: #5a5c69;
        }

        body {
            font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background-color: #f8f9fc;
        }

        .sidebar {
            background: linear-gradient(180deg, var(--primary-color) 0%, #224abe 100%);
            min-height: 100vh;
            color: white;
            transition: all 0.3s;
        }

        .sidebar .nav-link {
            color: rgba(255, 255, 255, 0.8);
            margin: 5px 0;
            border-radius: 5px;
            padding: 10px 15px;
        }

        .sidebar .nav-link:hover {
            color: white;
            background-color: rgba(255, 255, 255, 0.1);
        }

        .sidebar .nav-link.active {
            color: white;
            background-color: rgba(255, 255, 255, 0.2);
        }

        .sidebar .nav-link i {
            margin-right: 10px;
        }

        .topbar {
            height: 70px;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
            background-color: white;
        }

        .card {
            border: none;
            border-radius: 0.35rem;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
            margin-bottom: 20px;
        }

        .card-header {
            background-color: #f8f9fc;
            border-bottom: 1px solid #e3e6f0;
            padding: 1rem 1.35rem;
            font-weight: 600;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
        }

        .content-wrapper {
            padding: 20px;
        }

        /* 原有样式 */
        .container { max-width: 1000px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        .navbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
        h1 { color: #333; }
        .table { width: 100%; border-collapse: collapse; margin: 20px 0; }
        .table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
        .table th { background-color: #f8f9fa; font-weight: bold; }
        .table tr:hover { background-color: #f5f5f5; }
        .btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: button; text-decoration: none; display: inline-block; }
        .btn-primary { background: #007bff; color: white; }
        .btn-success { background: #28a745; color: white; }
        .btn-warning { background: #ffc107; color: black; }
        .btn-danger { background: #dc3545; color: white; }
        .btn:hover { opacity: 0.9; }
        .alert { padding: 15px; margin: 20px 0; border-radius: 4px; }
        .alert-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
        .alert-error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
        .action-buttons { display: flex; gap: 5px; }

        @media (min-width: 768px) {
            .sidebar {
                width: 14rem !important;
            }
        }
    </style>
</head>
<body>
<div class="d-flex">
    <!-- 侧边栏导航 -->
    <div class="sidebar flex-shrink-0 p-3" style="width: 250px;">
        <div class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
            <span class="fs-4">AI简历分析系统</span>
        </div>
        <hr>
        <ul class="nav nav-pills flex-column mb-auto">
            <li class="nav-item">
                <a th:href="@{/admin/interview_admin}" class="nav-link">
                    <i class="bi bi-speedometer2"></i>
                    控制面板
                </a>
            </li>
            <li>
                <a th:href="@{/admin/users}" class="nav-link active">
                    <i class="bi bi-people"></i>
                    用户管理
                </a>
            </li>
            <li>
                <a th:href="@{/admin/profile}" class="nav-link">
                    <i class="bi bi-person"></i>
                    个人资料
                </a>
            </li>
            <li>
                <a th:href="@{/admin/setup}" class="nav-link">
                    <i class="bi bi-gear"></i>
                    系统设置
                </a>
            </li>
            <li>
                <a th:href="@{/interview}" class="nav-link">
                    <i class="bi bi-file-earmark-text"></i>
                    简历分析
                </a>
            </li>
        </ul>
    </div>

    <!-- 主内容区 -->
    <div class="flex-grow-1">
        <!-- 顶部导航栏 -->
        <nav class="topbar mb-4 static-top shadow">
            <div class="container-fluid d-flex justify-content-end align-items-center h-100">
                <div class="d-flex align-items-center">
                    <div class="me-3">
                        <span class="text-dark" th:text="${currentUser.username} + ' (' + ${currentUser.email} + ')'"></span>
                    </div>
                    <div class="dropdown">
                        <a href="#" class="d-flex align-items-center text-decoration-none dropdown-toggle" id="dropdownUser" data-bs-toggle="dropdown" aria-expanded="false">

                            <div th:unless="${currentUser.avatarUrl}" class="user-avatar bg-primary text-white d-flex align-items-center justify-content-center">
                                <span th:text="${currentUser.email?.substring(0,1)?.toUpperCase()}"></span>
                            </div>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end shadow" aria-labelledby="dropdownUser">
                            <li><a class="dropdown-item" th:href="@{/admin/profile}">个人资料</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" th:href="@{/logout}">退出登录</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </nav>

        <!-- 内容区 -->
        <div class="content-wrapper">
            <div class="container-fluid">

                <div class="container">
                    <!-- 导航栏 -->
                    <div class="navbar">
                        <h1>用户管理系统</h1>
                        <div>
                            <a th:href="@{/admin/users/add}" class="btn btn-success">添加用户</a>
                        </div>
                    </div>

                    <!-- 消息提示 -->
                    <div th:if="${success}" class="alert alert-success" th:text="${success}"></div>
                    <div th:if="${error}" class="alert alert-error" th:text="${error}"></div>

                    <!-- 用户表格 -->
                    <table class="table">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>邮箱</th>
                            <th>密码</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="user : ${users}">
                            <td th:text="${user.id}"></td>
                            <td th:text="${user.email}"></td>
                            <td th:text="${user.password}"></td>
                            <td th:text="${user.createdAt}"></td>
                            <td class="action-buttons">
                                <a th:href="@{/admin/users/edit/{id}(id=${user.id})}" class="btn btn-warning">编辑</a>
                                <a th:href="@{/admin/users/delete/{id}(id=${user.id})}" class="btn btn-danger"
                                   onclick="return confirm('确定要删除这个用户吗？')">删除</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>